package com.project.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.project.bean.SupplierBean;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ISupplierMapper extends BaseMapper<SupplierBean> {
    IPage<SupplierBean> findByItem(Page pg, @Param("name") String name,
                                   @Param("business") String business);

    void addList(@Param("supplierList") List<SupplierBean> supplierList);

    @Select("SELECT ts.* FROM t_supplier ts,t_buyer tb WHERE " +
            "ts.pk_supplierId = tb.fk_supplierId AND tb.pk_buyerId = #{id}")
    @ResultMap("supplierMapper")
    SupplierBean findSup(Integer id);

    SupplierBean findByBuyerId(Integer buyerId);
}
